package demo;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class demo2 {
	public static void main(String[] args) {

		List<String> strList = new ArrayList<String>();
		strList.add("111");
		System.out.println(strList.getClass()+"@"+strList.hashCode());
		
		test1(strList);
		System.out.println(strList.getClass()+"@"+strList.hashCode());
		
		Iterator<String> iterator = strList.iterator();
		while(iterator.hasNext()){
			System.out.println(iterator.next());
		}
		System.out.println();
	}

	private static void test1(List<String> strList) {
		
		// 如果strList new ArrayList<String>(); strList变量在内存中会指向新的地址. 从而不能改变入参之前的strList
		// strList = new ArrayList<String>();
		strList.add("zhangsan");
		strList.add("lisi");
		System.out.println(strList.getClass()+"@"+strList.hashCode());
	}
}
